package com.yexiao.cofe.business.pojo;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.*;
import com.yexiao.core.util.JSONUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;


/**
 * @author lkl
 * @since 2025/3/27
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@TableName("`order`")
public class Order {

    /**
     * 自增主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 订单id
     */
    @TableField(value = "order_id")
    private Long orderId;

    /**
     * 用户id
     */
    @TableField(value = "user_id")
    private String userId;

    /**
     * 门店id
     */
    @TableField(value = "store_id")
    private String storeId;

    /**
     * 取餐码
     */
    @TableField(value = "pickup_code")
    private Integer pickUpCode;

    /**
     * 订单状态 0-待支付,1-已支付,2-制作中,3-已完成,4-已取消
     */
    @TableField(value = "`status`")
    private Integer status;

    /**
     * 用户备注
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 逻辑删除。0-未删除,1-已删除
     */
    @TableField("have_del")
    @TableLogic
    private Integer haveDel;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private String createTime;

    /**
     * 更新时间
     */
    @TableField("update_time")
    private String updateTime;

    public static final String ID = "id";
    public static final String ORDER_ID = "order_id";
    public static final String USER_ID = "user_id";
    public static final String STORE_ID = "store_id";
    public static final String PICKUP_CODE = "pickup_code";
    public static final String STATUS = "status";
    public static final String REMARK = "remark";
    public static final String HAVE_DEL = "have_del";
    public static final String CREATE_TIME = "create_time";
    public static final String UPDATE_TIME = "update_time";

    public static JSONObject getBaseMsg(Order order) {
        return JSONUtil.of(
                "orderId", String.valueOf(order.getOrderId()),
                "userId", order.getUserId(),
                "storeId", order.getStoreId(),
                "status", order.getStatus(),
                "remark", order.getRemark(),
                "createTime", order.getCreateTime(),
                "updateTime", order.getUpdateTime()
        );
    }
}
